package com.zmm.util.auth.registry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.stereotype.Component;

/**
 * @author 900045
 * @description:
 * @name AuthenticationRegistry
 * @date By 2021-07-06 09:22:58
 */
public class AuthenticationRegistry implements ImportBeanDefinitionRegistrar {


	private Logger logger       = LoggerFactory.getLogger(this.getClass());

	/**
	 * 要扫描的包
	 */
	private static final String PACKAGE_AUTH = "com.zmm.util.auth";


	@Override
	public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {

		logger.info("auth scan: {}", PACKAGE_AUTH);
		ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(registry, false);
		//扫描 @Component  注解的类
		AnnotationTypeFilter typeFilter = new AnnotationTypeFilter(Component.class, false);
		scanner.addIncludeFilter(typeFilter);
		scanner.scan(PACKAGE_AUTH);
		
	}
}
